package com.wjl.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.wjl.generator.MainGenerator;
import com.wjl.mode.MainTemplateConfig;
import lombok.Data;
import picocli.CommandLine;

import java.util.concurrent.Callable;

@CommandLine.Command(name = "generate",description = "生成代码", mixinStandardHelpOptions = true)
@Data
public class GeneratorCommand implements Callable<Integer> {

    @CommandLine.Option(names = {"-a", "--author"}, description = "作者", arity = "0..1", interactive = true,echo = true)
    private String author;

    @CommandLine.Option(names = {"-o", "--outputText"}, description = "输出", arity = "0..1", interactive = true,echo = true)
    private String outputText;

    @CommandLine.Option(names = {"-l", "--loop"}, description = "循环", arity = "0..1", interactive = true,echo = true)
    private boolean loop;


    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        mainTemplateConfig.setAuthor(author);
        mainTemplateConfig.setOutputText(outputText);
        mainTemplateConfig.setLoop(loop);
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
